
/*
* PurchasersDAL
*/
using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// Purchasers 的摘要说明。
	/// </summary>
	public class Purchasers : BaseDAL<PurchasersInfo>, IPurchasers
	{
		#region 对象实例及构造函数

		public static Purchasers Instance
		{
			get
			{
				return new Purchasers();
			}
		}
		public Purchasers() : base("purchasers","PurchaserNo")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override PurchasersInfo DataReaderToEntity(IDataReader dataReader)
		{
			PurchasersInfo purchasersInfo = new PurchasersInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			
			purchasersInfo.PurchaserNo = reader.GetString("PurchaserNo");
			purchasersInfo.UserID = reader.GetInt64("UserID");
			purchasersInfo.Type = reader.GetInt32("Type");
			purchasersInfo.ShortName = reader.GetString("ShortName");
			purchasersInfo.Company = reader.GetString("Company");
			purchasersInfo.Mobile = reader.GetString("Mobile");
			purchasersInfo.Tel = reader.GetString("Tel");
			purchasersInfo.Fax = reader.GetString("Fax");
			purchasersInfo.Email = reader.GetString("Email");
			purchasersInfo.Contact = reader.GetString("Contact");
			purchasersInfo.ZipCode = reader.GetString("ZipCode");
			purchasersInfo.Place = reader.GetString("Place");
			purchasersInfo.Address = reader.GetString("Address");
			purchasersInfo.Notes = reader.GetString("Notes");
			purchasersInfo.Licence = reader.GetString("Licence");
			purchasersInfo.IDCard = reader.GetString("IDCard");
			purchasersInfo.Scope = reader.GetString("Scope");
			purchasersInfo.Sales = reader.GetInt64("Sales");

			
			return purchasersInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
		protected override Hashtable GetHashByEntity(PurchasersInfo obj)
		{
			PurchasersInfo info = obj as PurchasersInfo;
			Hashtable hash = new Hashtable(); 
			
			
			hash.Add("PurchaserNo", TypeHelper.SafeString(info.PurchaserNo));
			hash.Add("UserID", TypeHelper.SafeInt(info.UserID));
			hash.Add("Type", TypeHelper.SafeInt(info.Type));
			hash.Add("ShortName", TypeHelper.SafeString(info.ShortName));
			hash.Add("Company", TypeHelper.SafeString(info.Company));
			hash.Add("Mobile", TypeHelper.SafeString(info.Mobile));
			hash.Add("Tel", TypeHelper.SafeString(info.Tel));
			hash.Add("Fax", TypeHelper.SafeString(info.Fax));
			hash.Add("Email", TypeHelper.SafeString(info.Email));
			hash.Add("Contact", TypeHelper.SafeString(info.Contact));
			hash.Add("ZipCode", TypeHelper.SafeString(info.ZipCode));
			hash.Add("Place", TypeHelper.SafeString(info.Place));
			hash.Add("Address", TypeHelper.SafeString(info.Address));
			hash.Add("Notes", TypeHelper.SafeString(info.Notes));
			hash.Add("Licence", TypeHelper.SafeString(info.Licence));
			hash.Add("IDCard", TypeHelper.SafeString(info.IDCard));
			hash.Add("Scope", TypeHelper.SafeString(info.Scope));
			hash.Add("Sales", TypeHelper.SafeInt(info.Sales));

			
			return hash;
		}
	}
}
